package com.tanhua.server.controller;

import com.tanhua.common.pojo.Question;
import com.tanhua.server.service.QuestionService;
import com.tanhua.server.vo.NearUserVo;
import com.tanhua.server.vo.RecommendUserQueryParam;
import com.tanhua.server.service.TodayBestService;
import com.tanhua.server.vo.PageResult;
import com.tanhua.server.vo.TodayBest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/tanhua")
@Slf4j
public class TodayBestController {
    @Autowired
    TodayBestService todayBestService;
    @GetMapping("todayBest")
    public ResponseEntity<TodayBest> queryTodayBest(@RequestHeader("Authorization") String token) {
        try {
            TodayBest todayBest = todayBestService.queryTodayBest(token);
            if (todayBest != null) {
                return ResponseEntity.ok(todayBest);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
    }



    @GetMapping("/recommendation")
    public ResponseEntity<PageResult> queryRecommendation(@RequestHeader("Authorization") String token, RecommendUserQueryParam queryParam){
        try {
            PageResult pageResult=todayBestService.queryRecommendation(token,queryParam);
             if(pageResult!=null){
                return ResponseEntity.ok(pageResult);
            }
        } catch (Exception e) {
            log.error("查询推荐用户列表出错~ token = " + token, e);
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
    }


}
